package com.dawn.modules.chat.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.dawn.modules.chat.entity.Note;
import com.dawn.modules.chat.mapper.NoteMapper;
import com.dawn.modules.chat.service.NotebookService;
import com.dawn.modules.chat.service.NoteService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;


@Service
public class NoteServiceImpl extends ServiceImpl<NoteMapper, Note> implements NoteService {

    @Resource
    private NotebookService notebookService;


    @Override
    public Integer addNote(Integer userId, String noteBookName, String title, String content) {
        Note note = Note.builder().title(title).content(content).build();
        // 保存后，主键会自动回填到 note 对象中
        save(note);
        notebookService.addNoteToNoteBook(userId, noteBookName, note.getNoteId());
        return note.getNoteId();
    }
}
